
          $('document').ready(function() {
                    $('#upload_product').change(function(){
                    $('#loading').removeClass("hide");
                    $('#file_upload_form').submit();
                    $('#prfl_pic').attr({src: 'img/loading.gif'});
                    //hide popup
                    $('#chng_prfl_pht_link').removeClass("hide");
                    //$('#chng_prfl_pht_popup').addClass("hide");
            });
    		});        
						function init()
            {
							alert("init function");
                document.getElementById("file_upload_form").onsubmit=function()
                {
                    document.getElementById("upload_target").onload = uploadDone(); //This function should be called when the iframe has compleated loading
                            // That will happen when the file is completely uploaded and the server has returned the data we need.
                }
            }
            function uploadDone()
            { //Function will be called when iframe is loaded
                var ret = frames['upload_target'].document.getElementsByTagName("body")[0].innerHTML;
                var data = eval("("+ret+")"); //Parse JSON 
                str = data.file_name;
                alert("str="+str);
                if(str){
                    $('#cropbox').attr({src: str});
										$('#image-path').attr({value: str});
                    $('#crop_image_src').attr({value: str});
                }
                else
                    $('#cropbox').attr({src: 'product/'+'<?php echo $usr_nmbr; ?>'+'/pp_'+'<?php echo $usr_nmbr; ?>'+'.jpg'});                    
								//$('#save-banner-form').removeClass("hide");
                //$('.loading').addClass("hide");
                //Apply crop box
                $('#cropbox').Jcrop({
                    aspectRatio: .85,
                    onSelect: updateCoords
                  });
                    $('#crop-button').show();              
                
            }

          function validate_product(){
                    var path = $("#product_image_path").val($("#cropbox").attr("src"));
                    alert(path);
           return true;         
          }